package org.goyo.main.domain.entity.sale;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.goyo.main.domain.entity.BaseEntryObject;
import org.goyo.main.domain.entity.base.BaseUnitMeasure;
import org.goyo.main.domain.entity.base.Customer;
import org.goyo.main.domain.entity.base.Material;
import org.goyo.main.domain.entity.base.MaterialEntry;
/**
 * 发运单分录
 * 
 * @author chenchuan
 * 2014年11月12日
 */
@Entity
public class DispatchEntry extends BaseEntryObject implements Serializable {

	private static final long serialVersionUID = 1L;
	
	/**
	 * 销售订单
	 *//*
	@ManyToOne
	@JoinColumn(name="saleOrderId")
	private SaleOrder saleOrder;*/
	/**
     * 销售订单分录
     */
    @ManyToOne
    @JoinColumn(name="saleOrderEntryId")
	private SaleOrderEntry saleOrderEntry;
	
	@ManyToOne
	@JoinColumn(name="materialId")
	private Material material;
	/**
	 * 商品名称	
	 */
	@Column
	private String materialName;
	/**
	 * 商品规格型号	
	 */
	@Column
	private String materialStandard;
	/**
	 * 基本计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="jilUnitId")
	private BaseUnitMeasure jilUnit;
	/**
	 * 数量	
	 */
	@Column
	private double dispatchQty = 0;
	
	/**
	 * 辅助计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="fjilUnitId")
	private MaterialEntry fjilUnit;
	
	   /**
     * 辅助换算率
     */
    @Column
    private String conversionRate;
	/**
	 * 辅助数量	
	 */
	@Column
	private double fdispatchQty = 0;
	/**
	 * 收货方	
	 */
	@ManyToOne
	@JoinColumn(name="consigneeId")
	private Customer consignee;
	/**
	 * 发运路线	
	 */
	@Column
	private String dispatchBus;
	/**
	 * 起运站	
	 */
	@Column
	private String startPoint;
	/**
	 * 到货站	
	 */
	@Column
	private String aogPoint;
	/**
	 * 承运方	
	 */
	@Column
	private String shipper;
	/**
	 * 车辆	
	 */
	@Column
	private String car;
	/**
	 * 司机	
	 */
	@Column
	private String driver;
	/**
	 * 签收数量	
	 */
	@Column
	private double signInQty = 0;
	/**
	 * 签收日期	
	 */
	@Column
	private String signInDate;
	/**
	 * 途损数量	
	 */
	@Column
	private double lossQty = 0;
	/**
	 * 途损处理方式	
	 */
	@Column
	private String lossHanWay;
	/**
	 * 途损金额	
	 */
	@Column
	private BigDecimal lossAmount = BigDecimal.ZERO;
	
	/**
	 * 累计出库数量
	 */
	@Column
	private double sumOutQty = 0;
	
	@ManyToOne(cascade={CascadeType.MERGE})
	@JoinColumn(name="parentId")
	private Dispatch dispatch;
	
	public String getMaterialName() {
		return materialName;
	}
	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}
	public String getMaterialStandard() {
		return materialStandard;
	}
	public void setMaterialStandard(String materialStandard) {
		this.materialStandard = materialStandard;
	}
	public BaseUnitMeasure getJilUnit() {
		return jilUnit;
	}
	public void setJilUnit(BaseUnitMeasure jilUnit) {
		if(jilUnit != null &&("".equals(jilUnit.getUuid()) || jilUnit.getUuid()==null))
			this.jilUnit = null;
		else
			this.jilUnit = jilUnit;	
	}
	public String getDispatchBus() {
		return dispatchBus;
	}
	public void setDispatchBus(String dispatchBus) {
		this.dispatchBus = dispatchBus;
	}
	public String getStartPoint() {
		return startPoint;
	}
	public void setStartPoint(String startPoint) {
		this.startPoint = startPoint;
	}
	public String getAogPoint() {
		return aogPoint;
	}
	public void setAogPoint(String aogPoint) {
		this.aogPoint = aogPoint;
	}
	public String getShipper() {
		return shipper;
	}
	public void setShipper(String shipper) {
		this.shipper = shipper;
	}
	public String getCar() {
		return car;
	}
	public void setCar(String car) {
		this.car = car;
	}
	public String getDriver() {
		return driver;
	}
	public void setDriver(String driver) {
		this.driver = driver;
	}
	public String getSignInDate() {
		return signInDate;
	}
	public void setSignInDate(String signInDate) {
		this.signInDate = signInDate;
	}

	public String getLossHanWay() {
		return lossHanWay;
	}
	public void setLossHanWay(String lossHanWay) {
		this.lossHanWay = lossHanWay;
	}
	/*public SaleOrder getSaleOrder() {
		return saleOrder;
	}
	public void setSaleOrder(SaleOrder saleOrder) {
		if(saleOrder != null &&("".equals(saleOrder.getUuid()) || saleOrder.getUuid()==null))
			this.saleOrder = null;
		else
			this.saleOrder = saleOrder;	
	}*/
		
	public Material getMaterial() {
		return material;
	}
	public SaleOrderEntry getSaleOrderEntry() {
    return saleOrderEntry;
  }
  public void setSaleOrderEntry(SaleOrderEntry saleOrderEntry) {
    if(saleOrderEntry != null &&("".equals(saleOrderEntry.getUuid()) || saleOrderEntry.getUuid()==null))
      this.saleOrderEntry = null;
    else
      this.saleOrderEntry = saleOrderEntry; 
  }
  public void setMaterial(Material material) {
		if(material != null &&("".equals(material.getUuid()) || material.getUuid()==null))
			this.material = null;
		else
			this.material = material;	
	}
	public Customer getConsignee() {
		return consignee;
	}
	public void setConsignee(Customer consignee) {
		if(consignee != null &&("".equals(consignee.getUuid()) || consignee.getUuid()==null))
			this.consignee = null;
		else
			this.consignee = consignee;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public Dispatch getDispatch() {
		return dispatch;
	}
	public void setDispatch(Dispatch dispatch) {
		this.dispatch = dispatch;
	}
	public double getDispatchQty() {
		return dispatchQty;
	}
	public void setDispatchQty(double dispatchQty) {
		this.dispatchQty = dispatchQty;
	}
	public double getSignInQty() {
		return signInQty;
	}
	public void setSignInQty(double signInQty) {
		this.signInQty = signInQty;
	}
	public double getLossQty() {
		return lossQty;
	}
	public void setLossQty(double lossQty) {
		this.lossQty = lossQty;
	}
	public BigDecimal getLossAmount() {
		return lossAmount;
	}
	public void setLossAmount(BigDecimal lossAmount) {
		this.lossAmount = lossAmount;
	}
	public double getSumOutQty() {
		return sumOutQty;
	}
	public void setSumOutQty(double sumOutQty) {
		this.sumOutQty = sumOutQty;
	}

	public MaterialEntry getFjilUnit() {
    return fjilUnit;
  }
  public void setFjilUnit(MaterialEntry fjilUnit) {
    if(fjilUnit != null &&("".equals(fjilUnit.getUuid()) || fjilUnit.getUuid()==null))
      this.fjilUnit = null;
  else
      this.fjilUnit = fjilUnit;
  }
  public String getConversionRate() {
    return conversionRate;
  }
  public void setConversionRate(String conversionRate) {
    this.conversionRate = conversionRate;
  }
  public double getFdispatchQty() {
		return fdispatchQty;
	}
	public void setFdispatchQty(double fdispatchQty) {
		this.fdispatchQty = fdispatchQty;
	}
	
}
